#include "lasercameratrackinsview.h"
#include "ui_lasercameratrackinsview.h"

LaserCameraTrackInsView::LaserCameraTrackInsView(int styleIdIn,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LaserCameraTrackInsView)
{
    ui->setupUi(this);
    setGeometry(5,50,451,544);
    initialDisplayStyle(styleIdIn);
}

LaserCameraTrackInsView::~LaserCameraTrackInsView()
{
    delete ui;
}


void LaserCameraTrackInsView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->save_Btn->setGeometry(360,350,70,40);
        break;
    default:
        break;
    }
}


void LaserCameraTrackInsView::getInput(LaserCameraTrackInstruction &instructionParaOut)
{
    instructionParaOut.commentStr=ui->note_lineEdit->text();

    if(ui->radioButton_trackOn->isChecked())
    {
        instructionParaOut.isStart=true;
    }
    else
    {
        instructionParaOut.isStart=false;
    }
//    instructionParaOut.jobIndex=ui->lineEdit_jobIndex->text().toInt();

}


void LaserCameraTrackInsView::updateView()
{
    if(instructionPara.isStart)
    {
        ui->radioButton_trackOn->setChecked(true);
        ui->radioButton_trackOff->setChecked(false);
    }
    else
    {
        ui->radioButton_trackOn->setChecked(false);
        ui->radioButton_trackOff->setChecked(true);
    }
//    ui->lineEdit_jobIndex->setText(QString::number(instructionPara.jobIndex));
    ui->note_lineEdit->setText(instructionPara.commentStr);
}

void LaserCameraTrackInsView::changeLanguage(int language)
{
   //TODO
}


void LaserCameraTrackInsView::finishEditInstruction(LaserCameraTrackInstruction instructionParaIn,QString &instructionStrOut)
{
    instructionStrOut.clear();
    instructionStrOut="LASERCAMERA_TRACK ";
    if(instructionParaIn.isStart)
    {
        instructionStrOut+="ON ";
    }
    else
    {
        instructionStrOut+="OFF ";
    }


    instructionStrOut+=";//"+instructionParaIn.commentStr;

}



void LaserCameraTrackInsView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->setText("");
}

void LaserCameraTrackInsView::on_save_Btn_clicked()
{
    getInput(instructionPara);
    finishEditInstruction(instructionPara,instructionStr);
//    emit finishEditInstructionSignal();
    emit saveInstructionSignal(instructionStr);
}
